<?php

namespace App\Console\Commands\Tools\Camera;

use App\Kuafu\Shop\Model\ShopMonitorDataHourModel;
use App\Kuafu\Shop\Model\ShopMonitorDataModel;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;

class DeleteShopMonitorData extends Command
{
    protected $signature   = 'tools:delete-shop-monitor-data';
    protected $description = '删数据数据太多了！！！';

    public function handle()
    {
        $this->dealLastHour();
    }

    private function dealLastHour()
    {
        $delTime = Carbon::now()->subDays(3)->getTimestamp();

        for ($i = 1; $i < 10000; $i++) {
            $res = ShopMonitorDataModel::query()
                                       ->where('dataAt', '<', $delTime)
                                       ->limit(5000)
                                       ->delete();

            dump($i . ':' . $res);
            sleep(2);
        }

    }

}
